<?php
/**
 * 需要登录的页面 判断是否登录 未登录跳转至登录界面
 */
namespace app\user\Controller;

use Think\Controller;

class Common extends Controller {

	function __construct() {
		parent::__construct();

		$nowca = CONTROLLER_NAME . "/" . ACTION_NAME;

		$adname = $_COOKIE['user'];
		$AdminId = $_COOKIE['uid'];

		$loginca = "Index/login,Index/check_user"; //未登录允许访问的控制器和方法

		if (empty($adname) && strpos($loginca, $nowca) === false) {
			$url = __MODULE__; //跳转URL
			echo '<literal><script>window.top.location.href="' . $url . '/Index/login";</script></literal>';
			exit;
		}
	}

	function _empty() {
		header("HTTP/1.0 404 Not Found");
		$this->display('templet/admin/404.html');
	}

}